﻿@using Xunit;
@inherits TestContext
@code
{
    [Inject]
    private LibraryConfiguration LibraryConfiguration { get; set; } = new LibraryConfiguration();

    public FluentDialogTests()
    {
        Services.AddSingleton(LibraryConfiguration);
    }

    [Fact]
    public void FluentDialog_Default()
    {
        // Arrange && Act
        var cut = Render(@<FluentDialog>My dialog content</FluentDialog>);

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentDialog_HeaderFooter()
    {
        // Arrange && Act
        var cut = Render(

    @<FluentDialog Modal="true">
        <FluentDialogHeader ShowDismiss="true">
            Header content
        </FluentDialogHeader>
        <FluentDialogBody>
            Body content
        </FluentDialogBody>
        <FluentDialogFooter>
            Footer content
        </FluentDialogFooter>
    </FluentDialog>
        );

        // Assert
        cut.Verify();
    }

    [Fact]
    public void FluentDialog_OnlySingleFooter()
    {
        Assert.Throws<InvalidOperationException>(() =>
        {
            // Arrange && Act
            var cut = Render(

            @<FluentDialog Modal="true">
                <FluentDialogHeader ShowDismiss="true">
                    Header content
                </FluentDialogHeader>
                <FluentDialogBody>
                    Body content
                </FluentDialogBody>
                <FluentDialogFooter>
                    Footer content
                </FluentDialogFooter>

                <!-- Second footer -->
                <FluentDialogFooter>
                    Second invalid Footer
                </FluentDialogFooter>
            </FluentDialog>
            );

            // Assert
            var result = cut.Markup;
        });
    }
}
